﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CDCW.API;
using CGSB.AppCode;
using CDCW.Data;

namespace CDCW.Web.View.UCMangForm
{
    public partial class FMZL : FormUControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

            }
        }



        public override void initALLForm(string strFormCode)
        {
            base.initALLForm(strFormCode);
            new CommonHelp.BindData().BindFL(ddlHY, "1");
        }
        /// <summary>
        /// 重写父类的保存数据方法
        /// </summary>
        /// <param name="intFormID">数据ID</param>
        /// <param name="strActionType">操作类型("ADD":"添加","UPDATE":"修改")</param>
        /// <returns></returns>
        public override bool SaveForm(int intFormID, string strActionType, int pid)
        {
            //执行 父类的方法
            base.SaveForm(intFormID, strActionType);

            //保存数据
            JH_CG_FMZL Model = new JH_CG_FMZLB().GetEntity(d => d.ID == intFormID);
            Model.Name = txtName.Text;
            Model.danwei = txtDW.Text;
            Model.Details = txtXMXQ.Text;
            Model.dianhua = txtDH.Text;
            Model.dizhi = txtDZ.Text;
            Model.guanjianci = txtGJC.Text;
            Model.hangye = ddlHY.SelectedItem.Text;
            Model.Type = int.Parse(ddlHY.SelectedValue);
            Model.jibenqingkuang = txtJBZK.Text;
            Model.qq = txtQQ.Text;
            Model.Remark = ddlLX.SelectedItem.Text;
            Model.xm = txtXM.Text;
            Model.youxiang = txtYX.Text;
            Model.zheyao = txtDWZK.Text;

            Model.cglx = ddlcglx.SelectedValue;
            Model.cgxt = ddlcgxt.SelectedValue;
            Model.yfjd = ddlyfjd.SelectedValue;
            Model.hzfs = ddlhzfs.SelectedValue;
            Model.status = "0";
            return new JH_CG_FMZLB().Update(Model);
        }




        public override void initMangerForm(int intFormID, string strActionType)
        {
            base.initMangerForm(intFormID, strActionType);

            JH_CG_FMZL Model = new JH_CG_FMZLB().GetEntity(d => d.ID == intFormID);
            txtName.Text = Model.Name;
            txtDW.Text = Model.danwei;
            txtXMXQ.Text = Model.Details;
            txtDH.Text = Model.dianhua;
            txtDZ.Text = Model.dizhi;
            txtGJC.Text = Model.guanjianci;
            ddlHY.SelectedValue = Model.Type.ToString();
            txtJBZK.Text = Model.jibenqingkuang;
            txtQQ.Text = Model.qq;
            ddlLX.SelectedItem.Text = Model.Remark;
            txtXM.Text = Model.xm;
            txtYX.Text = Model.youxiang;
            txtDWZK.Text = Model.zheyao;


            ddlcglx.SelectedValue = Model.cglx;
            ddlcgxt.SelectedValue = Model.cgxt;
            ddlyfjd.SelectedValue = Model.yfjd;
            ddlhzfs.SelectedValue = Model.hzfs;


            if (UserInfo.UserRoleCode.TrimEnd(',') == "3")
            {
                contact.Visible = false;
                common.Visible = true;
            }
            //else
            //{
            //    common.Visible = false;
            //}

        }


    }
}